package com.imooc.flink.cdc;

import com.ververica.cdc.connectors.mysql.MySqlSource;
import com.ververica.cdc.connectors.mysql.table.StartupOptions;
import com.ververica.cdc.debezium.DebeziumSourceFunction;

import java.util.Properties;

public class CdcSource {
    private static final String TAG = "CDCSupport";

    public static DebeziumSourceFunction getSource() {
        Properties debeProp = new Properties();
        // 配置 Debezium在初始化快照的时候（扫描历史数据的时候） =》 不要锁表
        debeProp.setProperty("debezium.snapshot.locking.mode", "none");

        DebeziumSourceFunction source = MySqlSource.builder()
                .hostname("192.168.2.72")
                .port(3333)
                .username("redsync")
                .password("redsync")
                .databaseList("redmine")
//                .tableList("redmine.projects, redmine.issues, redmine.time_entries")
                .tableList("redmine.time_entries")
                .startupOptions(StartupOptions.initial())
                .deserializer(new RedmineDeserializationSchema())
                .debeziumProperties(debeProp)
                .build();

        return source;
    }
}